package com.cn.kabalifeuser.ui.order.fragment;

import android.view.View;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.cn.kabalifeuser.R;
import com.cn.kabalifeuser.base.BasePresenter;
import com.cn.kabalifeuser.base.LazyFragment;
import com.cn.kabalifeuser.ui.my.adapter.PagerAdapter;
import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 晓林 on 2020/9/8.
 * function: 商城订单
 */
public class MallOrderFragment extends LazyFragment implements OnTabSelectListener {

    @BindView(R.id.slitab)
    SlidingTabLayout slitab;
    @BindView(R.id.vp_type)
    ViewPager vpType;
    List<String> mList = new ArrayList<>();
    PagerAdapter mAdapter;
    private List<Fragment> mFragments = new ArrayList<>();

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected void onUserVisible() {

    }

    @Override
    protected int provideContentViewId() {
        return R.layout.tab_page;
    }

    @Override
    public void initView(View view) {
        super.initView(view);

        ButterKnife.bind(this, view);
        AddTitleListData();
        mFragments.add(MallOrderFragments.getInstance(4));
        mFragments.add(MallOrderFragments.getInstance(0));
        mFragments.add(MallOrderFragments.getInstance(1));
        mFragments.add(MallOrderFragments.getInstance(2));
        mFragments.add(MallOrderFragments.getInstance(3));
        mFragments.add(MallOrderAfterSaleFragments.getInstance(4));
        mAdapter = new PagerAdapter(getChildFragmentManager(), mList, mFragments);
        vpType.setAdapter(mAdapter);
        vpType.setOffscreenPageLimit((mList.size() - 1));
        slitab.setViewPager(vpType);
        slitab.setOnTabSelectListener(this);


    }

    private void AddTitleListData() {
        mList.clear();
        mList.add("全部");
        mList.add("待付款");
        mList.add("待发货");
        mList.add("待收货");
        mList.add("待评价");
        mList.add("售后");
    }

    @Override
    public void onTabSelect(int position) {

    }

    @Override
    public void onTabReselect(int position) {

    }
}

